<!--个人中心页面-->
<script setup>
import { ref } from 'vue'
import { Plus } from '@element-plus/icons-vue'
// import qs from "qs";
// import axios from "axios";
// import {ElMessage} from "element-plus";
//
// const user = ref(localStorage.user?JSON.parse(localStorage.user):null);
// const save =()=>{
//   let newUser = {id:user.value.id, nickname:user.value.nickname};
//   //处理头像上传
//   if(fileList.value.length>0){
//     //得到图片路径
//     let url = fileList.value[0].response.data;
//     //装到newUser中，给后端更新数据入库使用
//     newUser.imgUrl = url;
//     //装到user中，一会更新成功存入localStorage中
//     user.value.imgUrl = url;
//   }
//   console.log(newUser);
//   let data = qs.stringify(newUser);
//   axios.post('http://localhost:8080/v1/users/update',data)
//        .then((response)=>{
//          if(response.data.code==2001){
//            ElMessage.success('修改成功');
//            location.user = JSON.stringify(user.value);
//          }
//        })
// }
//
// const fileList = ref([])
// const dialogImageUrl = ref('')
// const dialogVisible = ref(false)
//
// const handleRemove = (uploadFile, uploadFiles) => {
//   console.log(uploadFile, uploadFiles)
// }
//
// const handlePictureCardPreview = (uploadFile) => {
//   dialogImageUrl.value = uploadFile.url
//       dialogVisible.value = true
// }
</script>

<template>
  <h3>个人资料</h3>
  <hr>
  <el-form label-width="100px" style="width: 500px;margin-top: 50px;">
    <el-form-item label="头像">
      <!--头像上传开始-->
      <el-upload
          v-model:file-list="fileList"
          action="http://localhost:8080/v1/upload"
          limit="1"
          name="file"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove"
      >
        <el-icon><Plus /></el-icon>
      </el-upload>

      <el-dialog v-model="dialogVisible">
        <img w-full :src="dialogImageUrl" alt="Preview Image" />
      </el-dialog>
      <!--头像上传结束-->
    </el-form-item>
    <el-form-item label="用户名">
      <el-input placeholder="请输入昵称"></el-input><!--v-model="user.nickname"-->
    </el-form-item>
    <el-form-item label="真实姓名">
      <!--disabled 只能看，不能改-->
      <el-input placeholder="请输入用户名"></el-input><!--:value="user.username" disabled-->
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group class="ml-4"><!--v-model="gender"-->
        <el-radio value="1" size="large">男</el-radio>
        <el-radio value="2" size="large">女</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="出生日期">
      <el-date-picker type="date" placeholder="选择日期"></el-date-picker>
    </el-form-item>
    <el-form-item label="身份证号码">
      <el-input placeholder="请输入身份证号码"></el-input><!--v-model="user.idCard"-->
    </el-form-item>
    <el-form-item label="固定电话">
      <el-input placeholder="请输入固定电话"></el-input><!--v-model="user.tel"-->
    </el-form-item>
    <el-form-item label="QQ号码">
      <el-input placeholder="请输入QQ号码"></el-input><!--v-model="user.qq"-->
    </el-form-item>
    <el-form-item label="邮政编码">
      <el-input placeholder="请输入邮政编码"></el-input><!--v-model="user.postCode"-->
    </el-form-item>
    <el-form-item label="联系地址">
      <el-select  placeholder="请选择" style="margin-bottom: 20px;"><!--v-model="user.country"-->
        <el-option label="中国" value="cn"></el-option>
        <el-option label="美国" value="us"></el-option>
        <el-option label="澳大利亚" value="au"></el-option>
        <el-option label="新西兰" value="nz"></el-option>
      </el-select>
      <el-input placeholder="请输入详细地址"
                style="height: 80px;"
                type="textarea"
                maxlength="150"
                show-word-limit
      ></el-input><!--v-model="user.address"-->
    </el-form-item>
    <el-form-item>
      <el-button type="primary">保存修改</el-button><!--@click="save()"-->
    </el-form-item>
  </el-form>
</template>

<style scoped>

</style>